package org.shijiagen.search.contorller;

import lombok.RequiredArgsConstructor;
import org.shijiagen.param.ProductSearchParam;
import org.shijiagen.pojo.Product;
import org.shijiagen.search.service.SearchService;
import org.shijiagen.utils.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("search")
@RequiredArgsConstructor
public class SearchController {

    private final SearchService searchService;

    @PostMapping("product")
    public R searchProduct(@RequestBody ProductSearchParam productSearchParam){
        return searchService.search(productSearchParam);
    }

    @PostMapping("save")
    public R saveProduct(@RequestBody Product product){
        return searchService.save(product);
    }

    @PostMapping("remove")
    public R removeProduct(@RequestBody Product product){
        return searchService.remove(product);
    }
}
